#!/usr/bin/env python
# -*- coding: utf-8 -*-

from typing import Any

from cta.impl.action.responsibility_chain_begin_action import ResponsibilityChainBeginAction
from cta.impl.action.responsibility_chain_end_action import ResponsibilityChainEndAction
from cta.interface.action.abstract_action import AbstractAction
from cta.interface.step.abstract_step import AbstractStep
from web.domain.responsibility_chain_dto import ResponsibilityChainDto
from web.manager.log_manager import LogManager

Logger = LogManager.get_logger(__name__)

class CreateOptimize2AccountLogProfitAndLossRatePictureStep(AbstractStep):
    """
    根据表optimize2_account_log中每个账号的总资金，生成折线图
    """

    def __init__(self, create_optimize2_account_log_profit_and_loss_rate_picture_action: AbstractAction, successor=None):
        super().__init__(successor)

        # 定义动作
        self.responsibility_chain_begin_action = ResponsibilityChainBeginAction()
        self.create_optimize2_account_log_profit_and_loss_rate_picture_action = create_optimize2_account_log_profit_and_loss_rate_picture_action
        self.responsibility_chain_end_action = ResponsibilityChainEndAction()
        # 定义动作顺序
        self.responsibility_chain_begin_action.set_successor(self.create_optimize2_account_log_profit_and_loss_rate_picture_action)
        self.create_optimize2_account_log_profit_and_loss_rate_picture_action.set_successor(self.responsibility_chain_end_action)

    def set_successor(self, successor):
        super().set_successor(successor)

    def exec(self, responsibility_chain_dto: ResponsibilityChainDto = None) -> Any:
        self.responsibility_chain_begin_action.exec(responsibility_chain_dto)
        super().next(responsibility_chain_dto)